<!DOCTYPE html>  
<html>
<head>  
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>浏览器定位</title>  
<!-- 开发的时候可以用版本2，上线的时候改回3既可以 -->
<script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=eQzkGfNYjZulq8yab9tvbS17w8tqQ8xv">
//v3.0版本的引用方式：src="https://api.map.baidu.com/api?v=3.0&ak=您的密钥"
</script>
</head>  
 
<body>  

<script type="text/javascript"> 

var myCity = new BMap.LocalCity();
myCity.get((res)=>{
    console.log('====================================');
    console.log('我是浏览器定位',res.address.city);
    console.log('====================================');
}); 
</script>  
</body>  
</html>